﻿//加载内容中的图片
function LoadContentImg() {
    $("#grapes_content img").each(function (i) {
        $(this).bind("click","",function(){
            Thumbnail(i);
        });
        $(this).attr("style","cursor:pointer;");
    });
}
//图片浏览
function Thumbnail(i) {
     //获取内容的所有图片标签并且存放到数组中
    var imgsrc = [];
    $("#grapes_content img").each(function (j) {
        imgsrc.push({
            src:this.src
        });
    });
    var count = i;
    $.dboxDialog({
        title: '',
        content: '<div style="text-align:center"><img alt="" src="' + imgsrc[i].src + '" /></div>',
        button: [
            {
                text: '上一张',
                callback: function () {
                    if (count > 0) {
                        count = count - 1;
                    }

                    this.content('<div style="text-align:center"><img alt="" src="' + imgsrc[count].src + '"  /></div>');
                    if (count == 0) {
                        art.dialog({
                            content:'这里是第一张图片了哦!',
                            time:1000
                        });
                    }
                    return false;

                }
            },
            {
                text: '下一张',
                callback: function () {
                    if (count < imgsrc.length - 1) {
                        count = count + 1;
                    }
                    this.content('<div style="text-align:center"><img alt="" src="' + imgsrc[count].src + '" /></div>');
                     if (count == imgsrc.length-1) {
                        $.dboxDialog({
                            content:'这里是最后一张图片了哦!',
                            time:1000
                        });
                    }
                    return false;
                }
            }
        ],
        cancel: true,
        cancelText: '关闭',
        width: 625,
        height: 470
    });
}